package com.leyou.item.mapper;

import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author shkstart
 * @create 2020-03-24 14:02
 */
public interface BrandMapper extends Mapper<Brand> {

    @Insert("insert into tb_category_brand values(#{cid},#{bid})")
    void insertCategoryAndBrand(@Param("cid") Integer cid,@Param("bid") Long bid);

    @Delete("delete from tb_category_brand where brand_id = #{id}")
    void deleteCategortAndBrandByBid(@Param("id") Long id);

    @Select("delete from tb_category_brand where brand_id = #{id}")
    void deleteTbCategoryAndBrand(@Param("id") Long id);

    @Select("select b.* from tb_brand b inner join tb_category_brand c on b.id=c.brand_id where c.category_id=#{cid}")
    List<Brand> queryBrandByCid(@Param("cid") Long cid);
}
